<template>
	<view class="inventoryReview">
		<watermark></watermark>
		<scroll-view scroll-y @scrolltolower="getMore">
			<view class="goods  zyjz f26 cl343 flex-start-c " v-for="(item,int) in items" :key="int">
				<image :src="item.img" mode="widthFix"></image>
				<view class="mgn-l-20" style="width:68%">
					<view class="omit1">
						{{item.goods_name}}
					</view>
					<view class="zyjz clAAA f24 mgn-b-40 mgn-t-30">
						<view class="f24 mgn-r-30">原有库存：{{item.wg_num}}</view>
						<view class="f24 clAAA" v-if="item.wg_num !== item.num">异常库存：{{item.num}}</view>
					</view>
					<view class="cl3e8" v-if="item.note">
						原因说明：{{item.note}}
					</view>
				</view>
			</view>
			<view style="height: 200rpx;"></view>

		</scroll-view>
		<view class="bottom zyjz pad-l-40 pad-t-20 pad-b-20 pad-r-20 bgfff f28 cl343 space-between "
			v-if="infoData.type === 'admin'">
			<button type="primary" style="width: 48%;" hover-class="none" @click="onPass">审核通过</button>
			<button type="default" style="width: 48%;" hover-class="none" plain @click="onRefuse">拒绝审核</button>
		</view>
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="input" title="拒绝原因" placeholder="请输入拒绝原因"
				@confirm="dialogInputConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import watermark from '@/components/watermark.vue'
	import mixins from '@/mixins/index.js'
	export default {
		mixins: [mixins],
		components: {
			watermark
		},
		data() {
			return {
				id: '',
				lists_url: 'count_goods',
				param: {
					page: 1,
					size: 20,
				},
				items: []
			}
		},
		onLoad(e) {
			if (e && e.id) {
				this.id = e.id
				this.param.orders_id = e.id
				this.get_lists();
			}
		},
		methods: {
			onPass() {
				const obj = {
					type: this.type,
					id: this.id,
					pass: 1,
				}
				this.api.post('audit', obj).then(res => {
					this.api.msg('审核成功')
					setTimeout(() => {
						this.back()
					}, 2000)
				})
			},
			onRefuse() {
				this.$refs.inputDialog.open()
			},
			dialogInputConfirm(val) {
				const obj = {
					type: this.type,
					id: this.id,
					pass: 2,
					note: val
				}
				this.api.post('audit', obj).then(res => {
					this.$refs.inputDialog.close()
					this.api.msg('拒绝成功')
					setTimeout(() => {
						this.back()
					}, 2000)
				})

			}
		}
	}
</script>

<style lang="less">
	.inventoryReview {

		.goods {
			position: relative;
			padding: 20rpx 0;
			margin: 0 20rpx;
			border-bottom: 1px solid #f7f7f7;

			.out {
				position: absolute;
				top: 20rpx;
				left: 0rpx;

				image {
					width: 48rpx;
					height: 48rpx;
				}

				text {
					position: absolute;
					top: 10rpx;
					left: 5rpx;
				}
			}

			image {
				width: 200rpx;
				height: 150rpx;
			}

			.clff0 {
				color: #FF0000;
			}
		}
	}
</style>